package com.example.studyproject.hutool;

import cn.hutool.core.date.*;

import java.util.Date;

/**
 * @program: StudyProject
 * @description: 日期函数工具类
 * @author: kangwei
 * @create: 2024-07-29 08:55
 **/
public class DateUtils {

    public static void main(String[] args) {
        System.out.println(DateUtil.date());

        System.out.println(DateUtil.toLocalDateTime(new Date()));
        // 某一年有多少天
        System.out.println(DateUtil.lengthOfYear(2014));

        System.out.println(DateUtil.formatDate(new Date()));
        System.out.println(DateUtil.monthEnum(new Date()));

        System.out.println(DateUtil.beginOfDay(new Date()));
        System.out.println(DateUtil.getZodiac(Month.JULY.getValue(),20));


        // 创建日期范围生成器
        DateTime start = DateUtil.parse("2021-01-31");
        DateTime end = DateUtil.parse("2021-03-31");
        DateRange range = DateUtil.range(start, end, DateField.MONTH);
        System.out.println(range);
    }
}
